select
	adsource
	,accountid
	,COUNT(DISTINCT clickId) as gjocpcclick_click_cnt
from (
	select
		clickId,
		case when LENGTH (adsource)>0 then adsource else '-' end as adsource,
		case when LENGTH (accountId)>0 then accountId else '-' end as accountid
	from hdp_lbg_supin_clickhousedb.hdp_lbg_supin_hdp_lbg_zhaopin_gjocpc_click_new
	 where toYYYYMMDDhhmmss(`timestamp`) >=  '%s' and toYYYYMMDDhhmmss(`timestamp`) <  '%s'
) temp
group by
	adsource
	,accountid
WITH ROLLUP
having (adsource not in('','-') and accountid not in('','-'))
	or (adsource not in('','-') and accountid ='')
	or (adsource ='' and accountid ='');